#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START e2fsprogs-native

save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
export CFLAGS='-O2 -g'
unset CPPFLAGS
unset LDFLAGS

reset_mtime e2fsprogs e2fsprogs/configure.ac
rm -rf build/e2fsprogs-native
mkdir -p build/e2fsprogs-native
cd build/e2fsprogs-native

../../e2fsprogs/configure \
	${NATIVE_CONFIGURE_ARGS} \
	--enable-libblkid \
	--enable-libuuid \
	--disable-uuidd \
	--disable-fsck \
	${AUTOCRAP_KLUDGE}

make -j${JOBS}
make -j${JOBS} install DESTDIR=`pwd`/inst

# Only need mke2fs, tune2fs, and e2image
# XXX: fail if any of these are missing
set -o pipefail
mkdir -p -m755 "${xtools}${build_prefix}"
tar -c -f - -C inst${build_prefix} \
	bin/e2image \
	bin/mke2fs \
	bin/tune2fs \
	| \
tar -x -v -f - -C "${xtools}${build_prefix}"

cd ../..
rm -rf build/e2fsprogs-native

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

# RECIPE END e2fsprogs-native
